package com.changanw.permiss.controller;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

/**
 * @author changanw
 * @version ncc1.0
 * @description TODO
 * @date 2023/6/27 20:01
 */
@RestController
public class HelloController {
  @GetMapping("/hello")
  public void hello(){
    Collection<? extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities();
    for (GrantedAuthority authority : authorities) {
      System.out.println("authority " + authority);
    }
  }
}
